#coding=utf-8
products = [["Iphone","9000"] ,["华为","5000"] , ["三星","7000"]]
shop_car = []
exit_flag = False
while not exit_flag :
    print("-----商品列表----")
    for index , product in enumerate(products):
        print(" $$ %s -- %s -- %s " %(index , product[0] , product[1]))
    choice = input("请输入商品索引号 : \n ")
    if choice.isdigit():
        number = int(choice)
        if number > 0 and number < len(products):
            shop_car.append(products[number])
            print(" Add product %s into shopping cart " %(products[number]))
        else :
            print("%%%% 不是正确选项 @@@")
    elif choice == 'q':
        if len(shop_car):
            print("%% 购物车中有如下商品！  @@")
            for i , p in enumerate(shop_car):
                print("%s--%s--%s" %(i , p[0] , p[1]))
        exit_flag = True
    else :
        print("&& 选择异常！ @@")